import { useEditor } from "@craftjs/core"
import React from "react"

export const SettingPanel = () => {
    const {actions:{selectNode},component} = useEditor(state => {
        const {events:{selected}} = state
        const [selectedId] = Array.from(selected)

        return {
            selectedId,
            component: state.nodes[selectedId]?.related?.settings
        }
    })

    const Com = component ? component as unknown as React.ReactNode : null;

    return <>
    <div>
        {Com && React.createElement(Com as unknown as React.ComponentType)}
    </div>
    </>
}